package com.lhz.project.system.service.auth.impl;


import com.lhz.common.page.NewPageBean;
import com.lhz.project.system.mapper.base.LogMapper;
import com.lhz.project.system.model.entity.auth.OperateLog;
import com.lhz.project.system.model.entity.base.LoginLog;
import com.lhz.project.system.model.param.auth.LoginLogParam;
import com.lhz.project.system.model.param.auth.OperateLogParam;
import com.lhz.project.system.model.vo.auth.LoginLogVo;
import com.lhz.project.system.model.vo.auth.OperateLogInfoVo;
import com.lhz.project.system.model.vo.auth.OperateLogVo;
import com.lhz.project.system.service.base.LogService;
import jakarta.annotation.Resource;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @author LiHuaZhi
 * @since 2020-06-23 17:02:26
 */
@Service

public class LogServiceImpl implements LogService {
    @Resource
    private LogMapper logMapper;


    @Override
    public OperateLogInfoVo selectByPrimaryKey(String id) {
        return logMapper.selectByPrimaryKey(id);
    }

    @Override
    public Object listOperateLog(OperateLogParam param) {
        return NewPageBean.generatePage(() -> logMapper.listOperateLog(param), param, OperateLogVo.class);
    }

    @Override
    public Object listLoginLog(LoginLogParam param) {
        return NewPageBean.generatePage(() -> logMapper.listLoginLog(param), param, LoginLogVo.class);
    }

    /**
     * 系统日志
     *
     * @param log
     */
    @Override
    @Async
    public void insertOperateLog(OperateLog log) {
        logMapper.insertOperateLog(log);
    }

    /**
     * 登录日志
     *
     * @param log
     */
    @Override
    @Async
    public void insertLoginLog(LoginLog log) {
        logMapper.insertLoginLog(log);
    }
}